package edu.whu.puppygo.dao;

import edu.whu.puppygo.entity.Fragment;
import edu.whu.puppygo.entity.FragmentStatueEnum;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Collection;
import java.util.List;

public interface FragmentDao extends JpaRepository<Fragment, Long>, JpaSpecificationExecutor<Fragment> {
    @Query("select count(f) from Fragment f where f.conversationId = ?1")
    long countByConversationId(Long conversationId);


    @Query("select f from Fragment f where f.statue in ?1")
    List<Fragment> findByStatueIn(Collection<FragmentStatueEnum> statues);

}